// +build windows

package util

import (
	"gitee.com/gopher2011/gva/server/dao"
	"go.uber.org/zap/zapcore"
	"os"
	"path"
	"time"
)

func GetWriteSyncer() (zapcore.WriteSyncer, error) {
	fileWriter, err := rotatelogs.New(
		path.Join(dao.Cfg.Zap.Director+"%Y-%m-%d.log"), //拼接成log文件名
		rotatelogs.WithMaxAge(7*24*time.Hour),
		rotatelogs.WithRotationTime(24*time.Hour), //满24小时切割一次日志
	)
	if dao.Cfg.Zap.LogInConsole { //日志输出到控制台,日志输出到指定文件
		return zapcore.NewMultiWriteSyncer(zapcore.AddSync(os.Stdout), zapcore.AddSync(fileWriter)), err
	}
	// 日志输出到文件
	return zapcore.AddSync(fileWriter), err
}
